<script setup>
import { getArtistMv } from "../../../apis/user";
import { ref } from "vue";
import { useRoute } from "vue-router";
import { createWindow, ipcRendererSend } from "../../../utils/ipcRenderer";
const route = useRoute();

const simiMvList = ref([]);

const getInit = () => {
  getArtistMv({ id: route.query.id }).then((res) => {
    simiMvList.value = res.mvs;
  });
};
getInit();

const handleVideo = (id) => {
  createWindow({
    windowName: "videoDetail",
    path: "videoDetail",
    width: 1360,
    height: 820,
    param: { id: id },
  });
  ipcRendererSend("windows-param", {
    emit: "playVideo",
    targetName: "home",
  });
};
</script>

<template>
  <div class="mv_wrapper">
    <div class="video_wrap">
      <div class="item_wrap" v-for="(item, index) in simiMvList" :key="item.id">
        <div class="item">
          <div class="cover">
            <el-image
              @click="handleVideo(item.id)"
              :src="item.imgurl+`${'?param=300y300'}}`"
              fit="cover"
            >
              <template #placeholder>
                <div class="image-slot">
                  Loading<span class="dot">...</span>
                </div>
              </template>
            </el-image>
          </div>
          <div class="title">{{ item.name }}</div>
          <div class="name">{{ item.artistName }}</div>
        </div>
      </div>
    </div>
  </div>
</template>

<style scoped lang="scss">
.video_wrap {
  display: grid;
  justify-content: space-around;
  grid-template-columns: repeat(auto-fill, 16vw);

  .item_wrap {
    .item {
      margin-bottom: 20px;
      .cover {
        position: relative;
        height: 15vh;
        .el-image {
          width: 100%;
          height: 100%;
          border-radius: 13px;
          box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12), 0 0 6px rgba(0, 0, 0, 0.04);
          transition: all 0.3s;
        }
        .el-image:hover {
          transform: translateY(-8px);
        }
        .count {
          position: absolute;
          font-size: 8px;
          z-index: 5;
          top: 2%;
          right: 2%;
          color: #fff;
        }
        .el-icon-caret-right {
          font-size: 15px;
        }
        .time {
          position: absolute;
          font-size: 8px;
          z-index: 5;
          bottom: 2%;
          right: 2%;
          color: #fff;
        }
      }
      .title {
        font-size: 15px;
        font-weight: 600;
        line-height: 20px;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
      }
      .name {
        font-size: 10px;
        color: #6e6e69;
      }
    }
  }
}
</style>
